home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / DirectoryDialog.C < prev    next >
C/C++ Source or Header  |  1992-06-02  |  3KB  |  121 lines

  1. #ifdef __GNUG__
  2. #pragma implementation
  3. #endif
  4.  
  5. #include "DirectoryDialog.h"
  6.  
  7. #include "Class.h"
  8. #include "PopupItem.h"
  9. #include "ImageItem.h"
  10. #include "BorderItems.h"
  11. #include "Expander.h"
  12. #include "Buttons.h"
  13. #include "CheapText.h"
  14. #include "CollView.h"
  15. #include "OrdColl.h"
  16. #include "Directory.h"
  17. #include "Data.h"
  18. #include "Fields.h"
  19. #include "Form.h"
  20. #include "Menu.h"
  21. #include "Scroller.h"
  22. #include "System.h"
  23.  
  24. const int cIdDirOpen  =   cIdFirstUser + 130;
  25.  
  26. //---- DirectoryDialog ---------------------------------------------------------
  27.  
  28. NewMetaImpl0(DirectoryDialog,FileDialog);
  29.  
  30. DirectoryDialog *DirectoryDialog::gDirectoryDialog;
  31.  
  32. char *DirectoryDialog::GetDirectory(Window *w, EvtHandler *eh)
  33. {
  34.     if (gDirectoryDialog == 0)
  35.     gDirectoryDialog= new DirectoryDialog;
  36.     
  37.     if (gDirectoryDialog->ShowInWindow(eFDRead, w, eh, "Directory Name") == cIdOk)
  38.     return gSystem->WorkingDirectory();
  39.     return 0;
  40. }
  41.  
  42. ONEXIT(DirectoryDialog)
  43. {
  44.     SafeDelete(DirectoryDialog::gDirectoryDialog);
  45. }
  46.  
  47. DirectoryDialog::DirectoryDialog() : FileDialog("Directory Dialog")
  48. {
  49. }
  50.  
  51. VObject *DirectoryDialog::MakeFileItem(Data *data)
  52. {
  53.     FileItem *fi= new FileItem(data);
  54.     fi->Enable(data->IsDirectory(), FALSE);
  55.     return fi;
  56. }
  57.  
  58. VObject *DirectoryDialog::DoMakeContent()
  59. {
  60.     pathPopup= new PopupButton(cIdPath, cIdNone,
  61.                 new Menu("Current Directory", FALSE, FALSE));
  62.     
  63.     collview= new CollectionView(this, new OrdCollection, eCVDontStuckToBorder);
  64.     collview->SetMinExtent(Point(cItemMinWidth, 0));
  65.     collview->SetId(cIdList);
  66.  
  67.     return
  68.     new Matte(
  69.         new VExpander(20,
  70.         new Form(cIdNone, (VObjAlign)(eVObjVBase+eVObjHExpand), gPoint10,
  71.             "Current Directory:", pathPopup,
  72.             0
  73.         ), 
  74.         scroller= new Scroller(collview, Point(cItemMinWidth, ItemHeight()*cNumItems), cIdList),
  75.         new VExpander(gPoint2,
  76.             title,
  77.             eti= new TextField(cIdName, 20),
  78.             0
  79.         ),
  80.         new HBox(20, (VObjAlign)(eVObjVBase|eVObjHEqual|eVObjHExpand),
  81.             selectButton= new ActionButton(cIdDirOpen, "Select", TRUE),
  82.             openButton= new ActionButton(cIdOk, "Open"),
  83.             new ActionButton(cIdCancel, "Cancel"),
  84.             new ActionButton(cIdUpdate, "Update"),
  85.             0
  86.         ),
  87.         0
  88.         )
  89.     );
  90. }
  91.  
  92. void DirectoryDialog::DoSetup()
  93. {
  94.     bool e= FALSE;
  95.     if (eti->GetTextSize() > 0) {
  96.     char pathname[cPathBuf];
  97.     eti->GetString(pathname, cPathBuf);
  98.  
  99.     if (gSystem->ExpandPathName(pathname, cPathBuf-1))
  100.         return;
  101.  
  102.     FileData *fd= new FileData(pathname);
  103.     e= fd->IsDirectory();
  104.     delete fd;
  105.     }
  106.     openButton->Enable(e);
  107.     selectButton->Enable(e);
  108. }
  109.  
  110. void DirectoryDialog::Control(int id, int p, void *v)
  111. {
  112.     switch (id) {
  113.     case cIdDirOpen:
  114.     OpenOrChangeDir();
  115.     Dialog::Control(cIdOk, p, v);
  116.     return;
  117.     }
  118.     FileDialog::Control(id, p, v);
  119. }
  120.  
  121.